<?php
    $servername = "localhost";     //数据库服务器主机名
    $username = "root";           //数据库服务器用户名
    $password = "root";           //数据库服务器密码
    $database = "news";           //数据库名

    // 创建连接
    global $conn;
    $conn = @mysqli_connect($servername, $username, $password) or die("连接失败: " . mysqli_connect_error());;

    mysqli_select_db($conn, $database) or die("选择数据库失败: " . mysqli_error($conn));

?>